<?php

namespace app\http\middleware;

use think\facade\Cache;

class Qps
{
    public function handle($request, \Closure $next)
    {
        if ($request->header('token')) {
            if(Cache::get('qps_' . $request->header('token'))){
                abort(404, '404');
            }
            // 频率 1s 2s访问一次
            Cache::set('qps_' . $request->header('token'),true,1);
        }
        return $next($request);
    }
}
